package com.rjjs.Xiaozhi.service.impl;

import com.rjjs.Xiaozhi.entity.FoodPurchase;
import com.rjjs.Xiaozhi.mapper.FoodPurchaseMapper;
import com.rjjs.Xiaozhi.service.FoodPurchaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

@Service
public class FoodPurchaseServiceImpl implements FoodPurchaseService {
    @Autowired
    private FoodPurchaseMapper foodPurchaseMapper;
    @Override
    public List<FoodPurchase> selectFoodPurchase(String type) {
        FoodPurchase foodPurchase = new FoodPurchase();
        foodPurchase.setType(type);
        return  foodPurchaseMapper.selectFoodPurchase(foodPurchase);
    }

    @Override
    public int selectFoodPurchaseCount(String type, int state) {
        return foodPurchaseMapper.selectFoodPurchaseCount(type,state);
    }

    @Override
    public List<Integer> getCommodityWeek(String type, Integer state, String mondayOfWeek, String sundayOfWeek) {
        List<Integer> commodityWeek = foodPurchaseMapper.getCommodityWeek(type, state, mondayOfWeek, sundayOfWeek);
        while (commodityWeek.size()<5){
            commodityWeek.add(0);
        }
        return commodityWeek;

    }
}
